package tt.com.financialmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import tt.com.common.model.Order;
import tt.com.common.model.OrderProject;
import tt.com.common.util.PageUtil;
import tt.com.financialmanagement.mapper.OrderProjectMapper;
import tt.com.financialmanagement.service.OrderProjectService;

import java.util.List;

@Service
public class OrderProjectImpl extends ServiceImpl<OrderProjectMapper, OrderProject> implements OrderProjectService {
    @Override
    public ResponseEntity selectProject(Order order) {
        //判断传回来的项目id，订单项目是否拥有
        QueryWrapper<OrderProject> wrapper = new QueryWrapper<>();
        wrapper.eq("organ_id",order.getOrganId());
        List<OrderProject> orderProjects = baseMapper.selectList(wrapper);
        if (orderProjects.size()<0){
            return new ResponseEntity("该项目ID不存在", HttpStatus.INTERNAL_SERVER_ERROR);
        }
        QueryWrapper<OrderProject> qw=new QueryWrapper<>();
        qw.eq("data_status",1);
        qw.eq("organ_id",order.getOrganId());
        List<OrderProject> orderProjects1 = baseMapper.selectList(qw);
        return new ResponseEntity(orderProjects1,HttpStatus.OK);
    }
}
